#ifndef CHAT_CLIENT_H
#define CHAT_CLIENT_H

#include <QWidget>
#include <QTcpSocket>
class chat_client : public QObject
{
    Q_OBJECT

public:
    explicit chat_client(QObject *parent = nullptr);
    static chat_client* getInstance();
    ~chat_client();



signals:
    void fileListReceived(const QStringList &files);
    void fileDownloaded(const QString &filename, const QString &savepath);

    void newMsg_sig(QString msg);
    void disconnectd_sig();
    void onconnectd_sig();
private:
    QTcpSocket* client;
public:
    void requestFileList();
    void downloadFile(const QString &filename);

    void connetToserver(const QString &ip,const int &port);
    void sendToserver(const QString &id,const QString &msg);
    QString readForserver(const QString &msg);
private slots:
    void readyReadSlot();
    void onconnectd();
    void disconnectd();
};
#endif // CHAT_CLIENT_H
